package com.elcom.roaming.module.synthesis.isup;

import com.elcom.roaming.common.config.ConfigModule;
import com.elcom.roaming.common.util.match.ObjectKey;

public class ISUPKey extends ObjectKey{

	int seq;
	String desPntCode;
	String orgPntCode;
	String cirIdnCode;
	
	public ISUPKey(int seq, String time, String desPntCode, String orgPntCode, String cirIdnCode) {
		this.seq = seq;
		this.setPutTime(time);
		this.desPntCode = desPntCode;
		this.orgPntCode = orgPntCode;
		this.cirIdnCode = cirIdnCode;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof ISUPKey)) return false;
		
		ISUPKey cmpObj = (ISUPKey) obj;
		
		if (this == cmpObj) return true;

		if (this.getPutTimeInMs() - cmpObj.getPutTimeInMs() < ConfigModule.MISS_CALL_TIMEOUT * 1000 &&
				this.desPntCode.equals(cmpObj.desPntCode) &&
				this.orgPntCode.equals(cmpObj.orgPntCode) &&
				this.cirIdnCode.equals(cmpObj.cirIdnCode)) return true;
		
		return false;
	}

	@Override
	public int hashCode() {
		return desPntCode.hashCode() * orgPntCode.hashCode() * cirIdnCode.hashCode();
	}

	@Override
	public String toString() {
		return "seq=" + seq +
				"|time=" + getPutTime() +
				"|desPntCode=" + desPntCode +
				"|orgPntCode=" + orgPntCode +
				"|cirIdnCode=" + cirIdnCode;
	}

}
